'''
Created on 2012-7-7

@author: wb_suoyao.shen
'''
from django.shortcuts import get_object_or_404
from django.views.decorators.csrf import csrf_exempt
from django.shortcuts import render_to_response
from ssyblog.admin.models import AboutMe
from ssyblog.admin.forms import AboutMeForm

def aboutMe(request):
    about_me = AboutMe.objects.about_me()
    nav_parent = 'System Settind'
    nav_child = 'About Me'
    current_nav = 'about_me'
    return render_to_response('cms/admin/about_me.html',locals())

@csrf_exempt
def saveAboutMe(request,aboutId):
    if request.method == 'POST':
        if aboutId:
            about_to_update = get_object_or_404(AboutMe, pk = int(aboutId))
            form = AboutMeForm(request.POST,instance=about_to_update)
        else:
            form = AboutMeForm(request.POST)
        if form.is_valid():
            obj = form.save(commit=False)
            obj.save()
            tips = 'Post about me data success'
        else:
            tips = 'Post about me data failed'
    about_me = AboutMe.objects.about_me()
    nav_parent = 'System Settind'
    nav_child = 'About Me'
    current_nav = 'about_me'
    return render_to_response('cms/admin/about_me.html',locals())